//
//  YDOAFixedApprovalCell.swift
//  YDOAProduct
//
//  Created by 占益民 on 2017/11/7.
//  Copyright © 2017年 Allen. All rights reserved.
//

import UIKit

class YDOAFixedApprovalCell: UITableViewCell {

    var refuseCallBack : ((_ id:Int) -> Swift.Void)? = nil
    var passCallBack : ((_ id:Int) -> Swift.Void)? = nil
    
  
    
    @IBOutlet weak var lineLab: UILabel!
    @IBOutlet weak var refuseBtn: UIButton!
    @IBOutlet weak var passBtn: UIButton!
    
    @IBOutlet weak var applyUserLb: UILabel! //申请人
    @IBOutlet weak var countLb: UILabel! //申请数量
    @IBOutlet weak var uigeLb: UILabel! //规格
    @IBOutlet weak var goodsNameLb: UILabel! //物品名称
    @IBOutlet weak var refuseResonLb: UILabel!//拒绝理由
    @IBOutlet weak var refusePersion: UILabel!//拒绝人
    var model : YDOAFixedPropertyModel!{
        didSet{
            applyUserLb.text = "申请人: \( model.u_name ?? "")"
            countLb.text = "数量: \(model.num ?? 0)"
           
            uigeLb.text = "规格: \(model.guige ?? "")"
            goodsNameLb.text = "物品名称: \(model.goods_name ?? "")"
            if model.status == 2 {
                refuseResonLb.text = "拒绝理由: \(model.refuse_reson ?? "")"
                refusePersion.text = "拒绝人: \(model.ctr_id ?? 0)"
                refusePersion.isHidden = false
                refuseResonLb.isHidden = false
                refuseBtn.isHidden = true
                passBtn.isHidden = true
            }else if model.status == 1{
                refusePersion.isHidden = true
                refuseResonLb.isHidden = true
                refuseBtn.isHidden = true
                passBtn.isHidden = true
            }else{
                refuseBtn.isHidden = false
                passBtn.isHidden = false
            }
            
        }
    }
    /// 拒绝按钮点击
    ///
    /// - Parameter sender:闭包回调
    @IBAction func refuseBtnClick(_ sender: Any) {
        if refuseCallBack != nil {
            guard let ID = model.id else{return}
            refuseCallBack!(ID)
        }
    }
    
    /// 通过按钮点击
    ///
    /// - Parameter sender:闭包回调
    @IBAction func passBtnClick(_ sender: Any) {
        if refuseCallBack != nil {
            guard let ID = model.id else{return}
            passCallBack!(ID)
        }
    }
    override func awakeFromNib() {
        super.awakeFromNib()
     
        
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
